package org.dromara.common.log.event

import jakarta.servlet.http.HttpServletRequest
import java.io.Serial
import java.io.Serializable

/**
 * 登录事件
 *
 * @author Lion Li
 * @updater LikeYouDo
 * @date 2025/1/17 17:55
 */
data class LogininforEvent(

    /**
     * 租户ID
     */
    var tenantId: String? = null,

    /**
     * 用户账号
     */
    var username: String? = null,

    /**
     * 登录状态 0成功 1失败
     */
    var status: String? = null,

    /**
     * 提示消息
     */
    var message: String? = null,

    /**
     * 请求体
     */
    var request: HttpServletRequest? = null,

    /**
     * 其他参数
     */
    var args: Array<Any>? = null,

) : Serializable {
    companion object {
        @Serial
        private val serialVersionUID: Long = 1L
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (other !is LogininforEvent) return false

        if (tenantId != other.tenantId) return false
        if (username != other.username) return false
        if (status != other.status) return false
        if (message != other.message) return false
        if (request != other.request) return false
        if (args != null) {
            if (other.args == null) return false
            if (!args.contentEquals(other.args)) return false
        } else if (other.args != null) return false

        return true
    }

    override fun hashCode(): Int {
        var result = tenantId?.hashCode() ?: 0
        result = 31 * result + (username?.hashCode() ?: 0)
        result = 31 * result + (status?.hashCode() ?: 0)
        result = 31 * result + (message?.hashCode() ?: 0)
        result = 31 * result + (request?.hashCode() ?: 0)
        result = 31 * result + (args?.contentHashCode() ?: 0)
        return result
    }


}
